package com.gets.web.repository;

import com.gets.web.model.ImageSetListEntity;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

/**
 * Created by sjj on 2015/10/24 0024.
 */
@Repository // 添加注解
public interface ImageSetListRepository extends JpaRepository<ImageSetListEntity, Integer> {
    // 定义查询
    // @Param注解用于提取参数
    @Query("select ise from ImageSetListEntity ise where ise.category=:category")
     Page<ImageSetListEntity> getImageSetList(@Param("category") String category, Pageable pageable);

    @Query("select ise from ImageSetListEntity ise where ise.label like :keyword order by ise.like_count desc")
     Page<ImageSetListEntity> search(@Param("keyword") String keyword, Pageable pageable);

    @Query("select ise from ImageSetListEntity ise order by ise.like_count desc")
    Page<ImageSetListEntity> getBestImageSet(Pageable pageable);
}